$(function(){
	goToPage(1);
});


function goToPage(pageNo){
	var beginTime = $('#beginTime').val();
	var endTime = $('#endTime').val();
	var companyName = $('#companyName').val();
	$.ajax({
		url : contextPath+ 'admin/usercompanyref/list',
		data : {
			begintime:beginTime,
			endtime:endTime,
			companyName:companyName
		},
		type : 'POST',
		success : function(list) {
			$("#content").empty();
			if(list!=null && list.length>0){
				var count=0;
				for(var i=0;i<list.length;i++){
					count += list[i].number;
					var div = '<div class="pwsj_right_czrz_cont">';
					div += '<ul class="czrz_cont_ul">';
					div += '<li class="number" style="width: 19%">'+(i+1)+'</li>';
					div += '<li class="companyName" style="width: 40%;">'+list[i].company.companyName+'</li>';
					div += '<li class="count" style="width: 40%;border-right:none;">'+list[i].number+'</li>';
					div += '</ul>';
					div += '</div>';
					$("#content").append(div);
				}
				var end = '<div class="pwsj_right_czrz_cont">';
				end += '<ul class="czrz_cont_ul">';
				end += '<li class="number" style="width: 19%">合计</li>';
				end += '<li class="companyName" style="width: 40%"></li>';
				end += '<li class="count" style="width: 40%;border-right:none;">'+count+'</li>';
				end += '</ul>';
				end += '</div>';
				$("#content").append(end);
			}
		}
	});
}

function exportexcle(){
	if(confirm("确定导出对应模板数据吗？")){
		$("#exportimg").show();
		$.ajax({
			url : contextPath+ 'admin/excel/userstatistics',
			data : {
				beginTime : $("#beginTime").val(), 
				endTime : $("#endTime").val(),
				companyName : $("#companyName").val()
			},
			type : 'POST',
			success : function(data) {
				$("#exportimg").hide();
				if(data.opResult=="0"){
					var uploadurl = basePath + data.msgDesc;
					//alert(uploadurl);
					window.location.href = uploadurl;
				}else{
					alert(data.msgDesc);
				}
			}
		});
	}
}